Skip to content

fix(test): remove constant-kind exclusion from parity test (#676)#680

Merged
carlos-alm merged 2 commits intomainfrom
fix/native-constant-scope
Mar 30, 2026
Merged

fix(test): remove constant-kind exclusion from parity test (#676)#680
carlos-alm merged 2 commits intomainfrom
fix/native-constant-scope

Conversation

@carlos-alm
Copy link
Copy Markdown
Contributor

Summary

  • Remove the kind != 'constant' workaround from build-parity.test.ts — the underlying native engine scope bug was fixed in bug: WASM engine extracts 26 fewer nodes than native (engine parity gap) #649
  • Both engines now use identical FUNCTION_SCOPE_TYPES for constant extraction scope guards (function_declaration, arrow_function, function_expression, method_definition, generator_function_declaration, generator_function)
  • All three parity queries (nodes, edges, roles) now compare constant-kind rows

Closes #676

Test plan

  • CI parity test passes without the kind != 'constant' filter (requires native engine in CI)
  • No regression in other integration tests

The native engine's find_parent_of_types scope guard was fixed in #649
(added generator_function_declaration and generator_function). Both
engines now use identical scope filters for constant extraction, so the
kind != 'constant' workaround in the parity test is no longer needed.

Closes #676
@claude
Copy link
Copy Markdown

claude bot commented Mar 30, 2026

Claude finished @carlos-alm's task —— View job


PR Review Analysis

Reviewing PR #680: fix(test): remove constant-kind exclusion from parity test

Todo List:

  • Phase 1: Root cause analysis - understand what problem this PR solves
  • Phase 2: Configuration change detection - check for high-risk changes
  • Phase 3: Test integrity - verify tests aren't being weakened
  • Phase 4: Code quality assessment
  • Phase 5: Backlog compliance rating
  • Final Assessment: Provide comprehensive review and recommendation

Root Cause Analysis

Problem Being Solved: Removing a test workaround that masked an engine parity bug. The native Rust engine previously extracted function-scoped const declarations as top-level constants, while WASM correctly limited them to program-level scope.

Why This Approach: The underlying bug was fixed in #649/#327 by adding proper find_parent_of_types() scope guards to the native engine. Both engines now use identical function scope type lists, making the test filter unnecessary.

Risk Assessment: LOW RISK - This is removing a workaround after the root cause was fixed, not masking a problem.

Backlog Compliance

  • Zero-dep: ✓ — No new dependencies, removes test code only
  • Foundation-aligned: ✓ — Improves test coverage and engine parity validation
  • Problem-fit: 4 — Directly improves dual-engine reliability and prevents future parity regressions
  • Breaking: No — Test-only change, no API or behavior changes
  • Tier: 1

Critical Concerns

NONE - This is exactly the right approach after a root cause fix.

Analysis Summary

Phase 2: Configuration Changes ✅ PASS

  • No high-risk changes detected
  • Only removes test workaround code (11 lines deleted, 2 lines added)
  • No build config, linting rules, or timeout changes

Phase 3: Test Integrity ✅ PASS

Phase 4: Code Quality ✅ PASS

Phase 5: Backlog Compliance ✅ PASS

  • Zero-dep: ✓ No new runtime dependencies
  • Foundation-aligned: ✓ Improves dual-engine parity validation
  • Problem-fit: 4/5 - Directly prevents engine parity regressions
  • Breaking: No - Test-only change
  • Tier 1 classification

Final Recommendation

  • Rating: ⭐⭐⭐⭐☆ (4/5)
  • Action: APPROVE
  • Reasoning: This is the correct approach - removing a test workaround after fixing the underlying engine bug. The change strengthens test coverage by validating constant extraction parity between engines. Well-documented, low-risk, and directly improves reliability.

Minor note: Rating 4/5 instead of 5/5 only because this is a cleanup task rather than adding new functionality. The implementation is flawless for what it does.


@greptile-apps
Copy link
Copy Markdown
Contributor

greptile-apps bot commented Mar 30, 2026

Greptile Summary

This PR removes the kind != 'constant' workaround from all three parity queries in build-parity.test.ts, restoring full engine-parity coverage for constant-kind nodes, edges, and roles. The workaround was introduced to mask a native engine scope bug (local const inside functions being emitted as top-level constants) that has since been resolved in #649 by aligning FUNCTION_SCOPE_TYPES across both engines.

Key changes:

  • nodes query: WHERE kind != 'constant' filter removed — all node kinds are now compared.
  • edges query: WHERE n1.kind != 'constant' AND n2.kind != 'constant' filter removed — edges touching constant nodes are now compared.
  • roles query: AND kind != 'constant' filter removed — role rows for constants are now compared.
  • The explanatory bug comment block is also removed, keeping the file clean.

The change is consistent with the test file's own declared policy ("Do not weaken, skip, or filter this test to work around missing engine parity. Fix the code instead."). No logic, structure, or other test behaviour is affected. The skipped ast_nodes test (tracking separate issue #674) is unchanged and remains correctly deferred.

Confidence Score: 5/5

Safe to merge — removes a narrow workaround filter after the underlying engine bug was fixed, tightening test coverage with no risk of false positives.

The change is minimal, purposeful, and self-consistent: it removes three symmetric filter clauses that masked a now-fixed engine bug. No new logic is introduced, the test structure is unchanged, and the removal is explicitly endorsed by the file's own policy comment. No P0/P1 issues found.

No files require special attention.

Important Files Changed

Filename Overview
tests/integration/build-parity.test.ts Removes the kind != 'constant' workaround from all three parity queries (nodes, edges, roles) after the underlying native engine scope bug was fixed in #649; change is minimal, consistent, and aligned with the test file's own "do not weaken or filter" policy.

Sequence Diagram

sequenceDiagram
    participant Test as Parity Test
    participant WASM as WASM Engine
    participant Native as Native Engine
    participant DB_W as WASM SQLite DB
    participant DB_N as Native SQLite DB

    Test->>WASM: buildGraph(wasmDir, { engine: 'wasm' })
    WASM-->>DB_W: INSERT nodes (all kinds incl. constants)
    WASM-->>DB_W: INSERT edges
    WASM-->>DB_W: INSERT roles

    Test->>Native: buildGraph(nativeDir, { engine: 'native' })
    Native-->>DB_N: INSERT nodes (all kinds incl. constants)
    Native-->>DB_N: INSERT edges
    Native-->>DB_N: INSERT roles

    Note over Test: readGraph() — no kind filter (post #649 fix)

    Test->>DB_W: SELECT name, kind, file, line FROM nodes ORDER BY ...
    Test->>DB_N: SELECT name, kind, file, line FROM nodes ORDER BY ...
    Test->>Test: expect(nativeGraph.nodes).toEqual(wasmGraph.nodes)

    Test->>DB_W: SELECT ... FROM edges JOIN nodes ... ORDER BY ...
    Test->>DB_N: SELECT ... FROM edges JOIN nodes ... ORDER BY ...
    Test->>Test: expect(nativeGraph.edges).toEqual(wasmGraph.edges)

    Test->>DB_W: SELECT name, role FROM nodes WHERE role IS NOT NULL ORDER BY ...
    Test->>DB_N: SELECT name, role FROM nodes WHERE role IS NOT NULL ORDER BY ...
    Test->>Test: expect(nativeGraph.roles).toEqual(wasmGraph.roles)
Loading

Reviews (1): Last reviewed commit: "fix(test): remove constant-kind exclusio..." | Re-trigger Greptile

@carlos-alm carlos-alm merged commit 1a0e154 into main Mar 30, 2026
12 checks passed
@carlos-alm carlos-alm deleted the fix/native-constant-scope branch March 30, 2026 03:48
@github-actions github-actions bot locked and limited conversation to collaborators Mar 30, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(native): constant extraction scope bug — local const variables extracted as top-level constants

1 participant